package days25.title205;

import org.junit.Test;

import java.util.Arrays;

/**
 * @Author fengzihao
 * @Date 2024-05-09 21:20
 */
public class Solution {
    // @Test
    // public void test(){
    //     isIsomorphic("badc","baba");
    // }
    public boolean isIsomorphic(String s, String t) {
        if (s.length()==1)
            return true;
        char[] counts = new char[128];
        Arrays.fill(counts, (char) -130);
        char[] countt = new char[128];
        Arrays.fill(countt, (char) -130);
        boolean result = true;
        for (int i = 0; i < s.length(); i++) {
            char chs = s.charAt(i);
            char cht = t.charAt(i);
            if (counts[chs]==(char) -130&&countt[cht]==(char) -130){
                counts[chs] = cht;
                countt[cht] = chs;
            }
            else{
                if (cht!=counts[chs]||chs!=countt[cht])
                    return false;
            }
        }
        return true;
    }
}